#include "http-config.h"
#include <iostream>
void WebRouteMapper::addRoute(std::string uri, HttpController *controller) {
    WebRouteMapper::routeMap[uri] = controller;
}

void WebRouteMapper::setDefaultController(HttpController* ctrl) {
    WebRouteMapper::defaultController = ctrl;
}

void WebRouteMapper::setErrorController(int code, HttpController *ctrl) {
    errorRoute[code] = ctrl;
}


HttpController* WebRouteMapper::getController(std::string &uri) {
    if ( WebRouteMapper::routeMap.count(uri) == 0 ) {
        return WebRouteMapper::defaultController;
    } else {
        return WebRouteMapper::routeMap[uri];
    }
}

HttpController* WebRouteMapper::getErrorController(int code) {
    return errorRoute[code];
}